package com.book.config;

import com.book.utils.FileUtils;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


// 为了使上传的图片能保存到数据库中 这里要进行物理路径的映射
@Configuration
public class UploadMapping implements WebMvcConfigurer{

    // 设置请求路径和物理路径的映射关系
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        registry.addResourceHandler("/images/**")
                .addResourceLocations("file:" + FileUtils.getFilePath());

    }
}
